#pragma once

#include "includeBase.h"

#include "InputPropertyType.h"

class InputProperty
{
public:
    InputProperty();
    InputProperty(
        const QString& key,
        const QString& label,
        InputPropertyType type,
        bool editable = true
    );

    QString key() const;
    QString label() const;
    InputPropertyType type() const;
    bool editable() const;
    QVariant& defaultValue();
    QVariant& defaultValue2();

    QJsonObject* toJson();

    static InputProperty* fromJson(const QJsonValue& json);

    static void setJsonPropertyValue(
        QJsonObject* json,
        const QString& key,
        const InputPropertyType type,
        const QVariant& value
    );

    static void getJsonPropertyValue(
        const QJsonObject& json,
        const QString& key,
        const InputPropertyType type,
        QVariant& propValue
    );

    static InputPropertyType getJsonPropertyType(
        const QJsonObject& json,
        const QString& key
    );

    static void setJsonPropertyType(
        QJsonObject* json,
        const QString& key,
        const InputPropertyType value
    );

private:
    QString _key = "";
    QString _label = "";
    InputPropertyType _type = InputPropertyType::Text;
    QVariant _defaultValue;
    QVariant _defaultValue2;
    QVariant _min;
    QVariant _max;
    bool _editable = true;
};
